package com.cjj.navtong.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.os.Environment;

public class LocalUtils {
	
	//
	public static final String fileName = Environment.getExternalStorageDirectory()+"/jingjing.xml";
	/**
	 * 将文件存储在本地
	 * @param info
	 * @param context
	 */
	public static void storeFile(String info) {
		File file = new File(fileName);
		if (!file.exists()) {
			try {
				file.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		try {
			FileOutputStream fout = new FileOutputStream(fileName);
			
			byte[] bytes = info.getBytes();
			
			fout.write(bytes);
			
			fout.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static String timeFormat(long time){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
		return sdf.format(new Date(time));
	}
}
